package ucm;

import java.sql.Connection;
import java.sql.Statement;
import model.Database_Model;
import model.Line_Model;

public class UCDeleteLine {
    private String name;
    private Line_Model lm;

       public UCDeleteLine(view.Air_Manager man) {
        this.lm = man.getLineModel();

        this.name = lm.getName();
    }

    public String run() {
        boolean inserted = false;

        if (this.name.isEmpty()) {
            return "Please input your name in the list.";
        } else {
            //if (new ucm.UCCheckUser(name).run().equalsIgnoreCase("The user name already exists.")) {
            try {
                Connection con = new Database_Model().getConnection();
                Statement stmt = con.createStatement();
                stmt.executeUpdate("delete from airline where Airline = '" + name + "'");
                return "Congratulate! ";
            } catch (Exception e) {
                return "Failed! ";
            }
            //} else {
            //    return "The user name have not been used.";
            //}
        }
    }
}
